package net.linku.feign.fallback;

import net.linku.feign.Oauth2FeignClient;
import net.linku.feign.response.JwtToken;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

@Component
public class Oauth2ClientFallback implements Oauth2FeignClient {

    @Override
    public ResponseEntity<JwtToken> getToken(String username, String password, String grantType, String loginType, String basicToken, Long tenantId) {
        // 返回一个自定义的错误响应
        JwtToken fallbackToken = new JwtToken();
        fallbackToken.setAccessToken("fallback");
        fallbackToken.setTokenType("fallback");
        fallbackToken.setRefreshToken("fallback");
        fallbackToken.setExpiresIn(0L);
        fallbackToken.setScope("fallback");
        fallbackToken.setJti("fallback");
        return ResponseEntity.status(503).body(fallbackToken); // Service Unavailable
    }
}
